#pragma once
#include <vector>
#include <opencv2/opencv.hpp>
#include<algorithm>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;


struct point4Op
{
	Point2f calcpoint;
	Point2f realpoint;
	int xIdx;
	int yIdx;
};
class codiConvertor
{
public:
	Mat mapMartix;
	float loss;
	vector<point4Op> points4Op;

	codiConvertor() { mapMartix = Mat(); loss = 0; }
	void optimizer(float LR);
	double calcLoss(point4Op point);
	vector<double> getDerivative(point4Op& point);
};
bool cmp_x(point4Op x, point4Op y);
bool cmp_y(point4Op x, point4Op y);
float distance(cv::Point2f& a,cv::Point2f& b);
void point4Op_preinit(Mat frame,vector<point4Op> cornPoints);

